package com.ruoyi.project.good.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.good.mapper.GoodsPhotoMapper;
import com.ruoyi.project.good.domain.GoodsPhoto;
import com.ruoyi.project.good.service.IGoodsPhotoService;

/**
 * 商品图片Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-07-01
 */
@Service
public class GoodsPhotoServiceImpl implements IGoodsPhotoService 
{
    @Autowired
    private GoodsPhotoMapper goodsPhotoMapper;

    /**
     * 查询商品图片
     * 
     * @param photoId 商品图片ID
     * @return 商品图片
     */
    @Override
    public GoodsPhoto selectGoodsPhotoById(Long photoId)
    {
        return goodsPhotoMapper.selectGoodsPhotoById(photoId);
    }

    @Override
    public List<GoodsPhoto> selectGoodsPhotosByGoodId(Long goodId) {
        return goodsPhotoMapper.selectGoodsPhotosByGoodId(goodId);
    }

    /**
     * 查询商品图片列表
     * 
     * @param goodsPhoto 商品图片
     * @return 商品图片
     */
    @Override
    public List<GoodsPhoto> selectGoodsPhotoList(GoodsPhoto goodsPhoto)
    {
        return goodsPhotoMapper.selectGoodsPhotoList(goodsPhoto);
    }

    /**
     * 新增商品图片
     * 
     * @param goodsPhoto 商品图片
     * @return 结果
     */
    @Override
    public int insertGoodsPhoto(GoodsPhoto goodsPhoto)
    {
        goodsPhoto.setCreateTime(DateUtils.getNowDate());
        return goodsPhotoMapper.insertGoodsPhoto(goodsPhoto);
    }

    /**
     * 修改商品图片
     * 
     * @param goodsPhoto 商品图片
     * @return 结果
     */
    @Override
    public int updateGoodsPhoto(GoodsPhoto goodsPhoto)
    {
        return goodsPhotoMapper.updateGoodsPhoto(goodsPhoto);
    }

    /**
     * 批量删除商品图片
     * 
     * @param photoIds 需要删除的商品图片ID
     * @return 结果
     */
    @Override
    public int deleteGoodsPhotoByIds(Long[] photoIds)
    {
        return goodsPhotoMapper.deleteGoodsPhotoByIds(photoIds);
    }

    /**
     * 删除商品图片信息
     * 
     * @param photoId 商品图片ID
     * @return 结果
     */
    @Override
    public int deleteGoodsPhotoById(Long photoId)
    {
        return goodsPhotoMapper.deleteGoodsPhotoById(photoId);
    }

    @Override
    public int deleteGoodsPhotoByGoodsId(Long goodsId) {
        return goodsPhotoMapper.deleteGoodsPhotoByGoodsId(goodsId);
    }
}
